<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>

<%
	request.setAttribute("title","课题组详情");
	request.setAttribute("modelConfigPath", "group");
%>

<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style type="text/css">

</style>

<t:panel cssClass="panel-flat form-detailed form-xs" customBody="true" customHead="true">
	<div class="detailed-navbar-content panel-body">
		<t:form commandName="group" action="/admin/group/save" method="post" cssClass="form-horizontal">
			<div class="hide">
				<t:hidden path="groupId"/>
			</div>
			<t:formgroup>
				<t:label path="schoolId" cssClass="col-sm-2" />
				<t:select2 path="schoolId"  placeholder="选择学校"  colClass="col-sm-4" />
				<t:label path="academyId" cssClass="col-sm-2" />
				<t:select2 path="academyId" placeholder="选择学院" colClass="col-sm-4" />
			</t:formgroup>
			<t:formgroup>
				<t:label path="groupName" cssClass="col-sm-2" />
				<t:input path="groupName" colClass="col-sm-4" />
				<t:label path="dutyId" cssClass="col-sm-2"  />
				<t:select2 path="dutyId" colClass="col-sm-4" />
			</t:formgroup>
			<t:formgroup>
				<t:label path="comments" cssClass="col-sm-2"  />
				<t:textarea path="comments" rows="5" colClass="col-sm-10" />
			</t:formgroup>
		</t:form>
	</div>
	<t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<t:button icon="icon-floppy-disk" onclick="saveData()" cssClass="btn-info" csize="sm">保存</t:button>
	</t:panelFoot>
</t:panel>

<script type="text/javascript">
	$(function(){
		$("#schoolId").on("change",function(){
			loadAcademy($("#schoolId").val());
		});
		if($("#schoolId").val()!=null && $("#schoolId").val()!= '' ){
			loadAcademy($("#schoolId").val());
		}
	
	});
	function saveData(){
		if (!$("form:first").valid()){
			return;
		}
		$("form:first").submit();
	}
	
	function loadAcademy(schoolId){
		var selectId = null;
		var url = $.getVirtualPath()+"/admin/baseInfo/academy/getAcademyBySchoolId?schoolId="+schoolId;
		var items = $.getJson(url);
		selectId = $("#academyId").val(); 
		renderAcademy(items,selectId);
	}
	
	function renderAcademy(items,selectId){
		var options = [];
		if($.isNull(items)){
			$("#academyId").empty();	
			return null;
		}
		options.push("<option value=''></option>");
		$.each(items,function(index,item){
			if(item.value == selectId){
				options.push($("<option selected='selected' value='"+item.value+"'>"+item.text+"</option>"));
			}else{
				options.push($("<option value='"+item.value+"'>"+item.text+"</option>"));
			}
		});
		
		$("#academyId").empty();
		$("#academyId").append(options);
	}
</script>

<%@ include file="/WEB-INF/views/shared/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>